package violin.web;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import java.lang.reflect.Method;

public enum HttpMethod {
    Get {
        boolean matches(Method method) {
            return (method.isAnnotationPresent(GET.class)) || method.getName().equalsIgnoreCase("get");
        }
    },
    Post {
        boolean matches(Method method) {
            return (method.isAnnotationPresent(POST.class)) || method.getName().equalsIgnoreCase("create");
        }
    },
    Delete {
        boolean matches(Method method) {
            return (method.isAnnotationPresent(DELETE.class)) || method.getName().equalsIgnoreCase("delete");
        }
    },
    Put {
        boolean matches(Method method) {
            return (method.isAnnotationPresent(PUT.class)) || method.getName().equalsIgnoreCase("update");
        }
    };

    abstract boolean matches(Method method);

}
